﻿using MC;
using SASInspectionRY.Forms;
using Station.Common.Rejudgment;
using Station.Inspect.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Vision.Common;

namespace Station.Inspect
{
    public partial class FormInspect : Form
    {

        private double jogSpeed = 100;
        private int jogSpeedRadio = 50;
        private bool bLocation = false;
        FormSketch formSketch = null;
        public FormInspect()
        {
            InitializeComponent();

        }

        private void tbarJogSpeed_ValueChanged(object sender, EventArgs e)
        {
            jogSpeedRadio = tbarJogSpeed.Value;
            tbJogSpeed.Text = tbarJogSpeed.Value.ToString();
        }

        private void FormInspect_Load(object sender, EventArgs e)
        {
            //tbarJogSpeed_ValueChanged(null, null);
            ucPreView.ResetComponent(StaInspect.Instance.Prj.Components, StaInspect.Instance.Prj.Marks);
            AdjustLayOut();
            tbarJogSpeed.Value = jogSpeedRadio;
            cbInspectFace.SelectedIndex = (int)StaInspect.Instance.Mode;

            StaInspect.Instance.OnImageChanged += Instance_OnImageChanged;
            StaInspect.Instance.OnSketchChanged += Instance_OnSketchChanged;
            StaInspect.Instance.OnRejuding += Instance_OnRejuding;
            StaInspect.Instance.OnWorkModeChanged += Instance_OnWorkModeChanged;
            StaInspect.Instance.OnChangeLine += Instance_OnChangeLine;
            ucPreView.ucCanvas.MouseDown += UcCanvas_MouseDown;
            //StaConfig.Instance.Load();


            //MessageBox.Show("z A面高度"+StaConfig.Instance.OrgTopZ.ToString());
            StaInspect.Instance.Rbt.MoveAbsAxis(2, 1.5, StaInspect.Instance.Prj.g_dMaxVel, true);//控制Z轴动作
            txt_z.Text = StaInspect.Instance.Rbt.GetCurPos().z.ToString();
            txt_sudu.Text = StaInspect.Instance.Prj.g_dMaxVel.ToString();
            textBoxLight.Text = StaInspect.Instance.prjLight.ToString();
            StaInspect.Instance.ReadImageOnly();
        }

        private void Instance_OnWorkModeChanged(object sender, WorkModeEventArgs e)
        {
            this.Invoke(new Action<object, WorkModeEventArgs>(Instance_OnWorkModeChanged1), sender, e);
        }

        private void Instance_OnChangeLine(object sender, bool e)
        {

            if (this.InvokeRequired)
            {
                this.Invoke(new Action<object, bool>(Instance_OnChangeLine), sender, e);
            }
            else
            {
                chc_line.Checked = e;
            }
        }
        private void Instance_OnWorkModeChanged1(object sender, WorkModeEventArgs e)
        {
            if (e.PrjID == 0)
                rbFaceA.Checked = true;
            else
                rbFaceB.Checked = true;
            cbInspectFace.SelectedIndex = (int)e.Mode;
            ucPreView.ResetComponent(StaInspect.Instance.Prj.Components, StaInspect.Instance.Prj.Marks);
            ucSketch.Invalidate();
        }



        private void Instance_OnRejuding(object sender, ErrListEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new Action<object, ErrListEventArgs>(Instance_OnRejuding), sender, e);
            }
            else
            {
                FormRejudg form = new FormRejudg();
                form.Prj = e.Prj;
                form.ErrLst = e.ErrLst;
                form.Show();
            }
        }

        private void Instance_OnImageChanged(object sender, EventArgs e)
        {
            if (this.InvokeRequired)
            {
                //this.Invoke(new ImageChanged(Instance_OnImageChanged), sender, e);
                this.Invoke(new Action<object, EventArgs>(Instance_OnImageChanged), sender, e);
            }
            else
            {
                var BmpPt = StaInspect.Instance.CurBmpPt;
                tbCurPos.Text = BmpPt.pos.ToString();
                if (BmpPt != null)
                {
                    var ptStart = new Point(BmpPt.point.X - BmpPt.bitmap.Width / 2, BmpPt.point.Y - BmpPt.bitmap.Height / 2);
                    ucPreView.ucCanvas.ClearImg();
                    ucPreView.ucCanvas.AddImg(BmpPt.bitmap, ptStart);
                    ucPreView.ucCanvas.AutoSizeImage(false);
                    ucPreView.ucCanvas.Invalidate();
                    ucSketch.Invalidate();
                }
            }
        }

        private void Instance_OnSketchChanged(object sender, EventArgs e)
        {
            ucSketch.ClearImg();
            ucSketch.AddImg(StaInspect.Instance.Prj.sketchImg);
            ucSketch.AutoSizeImage();
            ucSketch.Invalidate();
        }

        private void btnJogMove_MouseDown(object sender, MouseEventArgs e)
        {
            try
            {
                var btn = sender as Button;
                string[] strs = btn.Tag.ToString().Split(',');
                int axis = int.Parse(strs[0]);
                int dir = int.Parse(strs[1]);
                if (btn.Text.IndexOf("Z") > -1)
                {
                    StaInspect.Instance.Rbt.MoveAbsAxis(2, dir > 0 ? 999 : -999, StaInspect.Instance.Prj.g_dMaxVel);
                }
                else
                {
                    StaInspect.Instance.Rbt.MoveAbsAxis(axis, dir > 0 ? 999 : -999, jogSpeed * jogSpeedRadio / 100.0);
                }


            }
            catch (Exception ex)
            {

            }
        }

        private void btnJogMove_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                StaInspect.Instance.Rbt.StopALL(true);
                StaInspect.Instance.ReadImageOnly();
                txt_z.Text = StaInspect.Instance.Rbt.GetCurPos().z.ToString();
            }
            catch (Exception ex)
            {

            }
        }

        private void btnSnap_Click(object sender, EventArgs e)
        {
            StaInspect.Instance.ReadImageOnly();
        }

        #region 菜单
        //工程-缩略图
        private void MenuItemProjectSketch_Click(object sender, EventArgs e)
        {
            FormSketch formSketch = FormDics.GetForm("formSketch") as FormSketch;
            if (formSketch == null)
            {
                formSketch = new FormSketch();
                FormDics.AddForm("formSketch", formSketch);
                formSketch.Show(this);
            }

        }
        //工程-程式
        private void MenuItemProjectPath_Click(object sender, EventArgs e)
        {
            FormPath formPath = FormDics.GetForm("formPath") as FormPath;
            if (formPath == null)
            {
                formPath = new FormPath();
                FormDics.AddForm("formPath", formPath);
                formPath.Show(this);
            }
        }
        //工程-保存
        private void MenuItemProjectSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(StaInspect.Instance.loadPath))
            {
                MessageBox.Show("请先选择要保存的路径");
                return;
            }

            StaInspect.Instance.Save(StaInspect.Instance.loadPath);
            StaConfig.Instance.Save(StaInspect.Instance.loadPath);
            MessageBox.Show("保存成功！");

        }
        //设置
        private void MenuItemConfig_Click(object sender, EventArgs e)
        {
            FormConfig form = FormDics.GetForm("formPath") as FormConfig;
            if (form == null)
            {
                form = new FormConfig();
                FormDics.AddForm("formPath", form);
                form.Show(this);
            }
        }
        #endregion
        private void FormInspect_Resize(object sender, EventArgs e)
        {
            AdjustLayOut();
        }

        private void AdjustLayOut()
        {
            int top = mainMenu.Height + mainTool.Height + 5;
            panelRight.Location = new Point(Width - panelRight.Width - 20, top);
            ucPreView.Location = new Point(5, top);
            ucPreView.Size = new Size(Width - panelRight.Width - 30, Height - top - 44);
            ucPreView.Invalidate();
        }

        private void tBtnSelect_Click(object sender, EventArgs e)
        {
            bLocation = false;
        }
        private void tBtnLocation_Click(object sender, EventArgs e)
        {
            bLocation = true;
        }
        private void UcCanvas_MouseDown(object sender, MouseEventArgs e)
        {
            if (bLocation)
            {
                var pt = ucPreView.ucCanvas.CurPosInImg;
                var curPt = new Point((int)pt.X, (int)pt.Y);
                var destPt = StaInspect.Instance.Rbt.P2TPByOrig(curPt);
                StaInspect.Instance.MoveAbsAndReadImage(destPt, jogSpeed * jogSpeedRadio / 100.0);
            }
        }
        private void ucSketch_DoubleClick(object sender, EventArgs e)
        {
            var pro = StaInspect.Instance.Prj.sketchProp;
            var pt = ucSketch.CurPosInImg;
            var curPt = new Point((int)(pt.X / pro), (int)(pt.Y / pro));
            var destPt = StaInspect.Instance.Rbt.P2TPByOrig(curPt);
            StaInspect.Instance.MoveAbsAndReadImage(destPt, jogSpeed * jogSpeedRadio / 100.0);
        }
        private void tBtnNodeLib_Click(object sender, EventArgs e)
        {
            FormNodeLib form = new FormNodeLib(NodeLibManager.nodeLibs);
            form.ShowDialog();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {

            using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.Description = "选择保存路径";
                DialogResult dialogResult = folderBrowserDialog.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    StaInspect.Instance.loadPath = folderBrowserDialog.SelectedPath;
                    StaInspect.Instance.Load(folderBrowserDialog.SelectedPath, true);
                    textBoxLight.Text = StaInspect.Instance.prjLight.ToString();
                    this.txt_sudu.Text = StaInspect.Instance.Prj.g_dMaxVel.ToString();
                    ucPreView.ResetComponent(StaInspect.Instance.Prj.Components, StaInspect.Instance.Prj.Marks);
                    txt_z.Text = StaInspect.Instance.Rbt.GetCurPos().z.ToString();
                    StaInspect.Instance.ReadImageOnly();
                }
            }


            //ucPreView.Components = StaInspect.Instance.Prj.Components;
            //ucPreView.Marks = StaInspect.Instance.Prj.Marks;

        }

        private void btnRun_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(StaInspect.Instance.loadPath))
            {
                MessageBox.Show("模板路径不能为空！");
                return;
            }
            StaInspect.Instance.StartInspect();
        }

        private void ucSketch_Paint(object sender, PaintEventArgs e)
        {
            var g = e.Graphics;
            float scale = (float)StaInspect.Instance.Prj.sketchProp;
            float prop = (float)(ucSketch.ScaleCur * scale);
            g.TranslateTransform(ucSketch.ImgOrgInPic.X, ucSketch.ImgOrgInPic.Y);
            g.ScaleTransform(prop, prop);
            if (StaInspect.Instance.CurBmpPt != null)
            {
                var centerPt = StaInspect.Instance.CurBmpPt.point;
                int lineLen = 100;
                g.DrawRectangle(Pens.Yellow, (centerPt.X - 2048), (centerPt.Y - 1500), 4096, 3000);
                g.DrawLine(Pens.Yellow, centerPt.X - lineLen, centerPt.Y, centerPt.X + lineLen, centerPt.Y);
                g.DrawLine(Pens.Yellow, centerPt.X, centerPt.Y - lineLen, centerPt.X, centerPt.Y + lineLen);
            }

            foreach (var item in ucPreView.ucCanvas.m_objList)
            {
                item.Draw(g, prop);
            }
        }

        private void cbRejudg_CheckedChanged(object sender, EventArgs e)
        {
            StaInspect.Instance.RejudgEnable = cbRejudg.Checked;
        }
        List<ErrCell> errCells = new List<ErrCell>();
        private void btnGetAllCell_Click(object sender, EventArgs e)
        {
            errCells.Clear();
            cmbCell.Items.Clear();
            foreach (var comp in StaInspect.Instance.Prj.Components)
            {
                foreach (var ele in comp.Elements)
                {
                    if (ele.Lib != null)
                    {
                        Matrix matrix = new Matrix();
                        matrix.Translate(ele.StartPoint.X, ele.StartPoint.Y);
                        matrix.Rotate(ele.Angle);
                        var pts = new PointF[1];
                        foreach (var cell in ele.Lib.NodeCells)
                        {
                            pts[0] = new PointF(cell.StartPoint.X + cell.Size.Width / 2, cell.StartPoint.Y + cell.Size.Height / 2);
                            matrix.TransformPoints(pts);

                            var errCell = new ErrCell();
                            errCell.ID = comp.ID + cell.ID;
                            errCell.Rect = cell.Rect;
                            errCell.Pos = pts[0];
                            errCells.Add(errCell);
                            cmbCell.Items.Add(errCell.ID.ToString());
                        }
                    }
                }
            }

        }

        private void cmbCell_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int i = cmbCell.SelectedIndex;
                var err = errCells[i];
                //var pos = new Point((int)err.Pos.X, (int)err.Pos.Y);
                TargetPos targetPos = StaInspect.Instance.Rbt.P2TPByOrig(err.Pos);
                tbCoorPixel.Text = $"{err.Pos.X},{err.Pos.Y}";
                tbCoorPos.Text = $"{targetPos.x},{targetPos.y}";
                label5.Text = $"状态：{err.Status}";
            }
            catch (Exception ex)
            {

            }
        }

        private void btnGoToCell_Click(object sender, EventArgs e)
        {
            try
            {
                var pos = tbCoorPos.Text.Split(',');
                TargetPos p = new TargetPos(double.Parse(pos[0]), double.Parse(pos[1]));
                StaInspect.Instance.MoveAbsAndReadImage(p, jogSpeed * jogSpeedRadio / 100.0);
            }
            catch (Exception ex)
            {

            }
        }

        private void cbInspectFace_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbInspectFace.SelectedIndex == 0)
            {
                StaInspect.Instance.Mode = WorkMode.AB;
                rbFaceA.Enabled = true;
                rbFaceB.Enabled = true;
                if (rbFaceA.Checked == false && rbFaceB.Checked == false)
                    rbFaceA.Checked = true;
            }
            else if (cbInspectFace.SelectedIndex == 1)
            {
                StaInspect.Instance.Mode = WorkMode.OA;
                rbFaceA.Enabled = true;
                rbFaceB.Enabled = false;
                rbFaceA.Checked = true;
            }
            else
            {
                StaInspect.Instance.Mode = WorkMode.OB;
                rbFaceA.Enabled = false;
                rbFaceB.Enabled = true;
                rbFaceB.Checked = true;
            }


        }

        private void rbFaceA_CheckedChanged(object sender, EventArgs e)
        {
            if (rbFaceA.Checked)
            {
                if (chc_line.Checked)
                {
                    StaInspect.Instance.initSwitch(0, 3);//设置检测模式
                  
                }
                else
                {
                    StaInspect.Instance.initSwitch(0);//设置检测模式
                    
                }
                textBoxLight.Text = StaInspect.Instance.prjLight.ToString();
                txt_z.Text = StaInspect.Instance.Rbt.GetCurPos().z.ToString();
                StaInspect.Instance.Rbt.StopALL(true);
                StaInspect.Instance.ReadImageOnly();
                StaInspect.Instance.Prj.g_dMaxVel = 300;
            }

        }

        private void rbFaceB_CheckedChanged(object sender, EventArgs e)
        {
            if (rbFaceB.Checked)
            {
                if (chc_line.Checked)
                {
                    StaInspect.Instance.initSwitch(1, 4);//设置检测模式
               
                }
                else
                {
                    StaInspect.Instance.initSwitch(1);//设置检测模式
                   
                }

               // StaInspect.Instance.Rbt.MoveAbsAxis(2, StaInspect.Instance.Prj.sketchOrig.z, StaInspect.Instance.Prj.g_dMaxVel, true);//控制Z轴动作
                txt_z.Text = StaInspect.Instance.Rbt.GetCurPos().z.ToString();
                textBoxLight.Text = StaInspect.Instance.prjLight.ToString();
                StaInspect.Instance.Rbt.StopALL(true);
                StaInspect.Instance.ReadImageOnly();
                StaInspect.Instance.Prj.g_dMaxVel = 300;
            }

        }
        private void chc_line_CheckedChanged(object sender, EventArgs e)
        {
            if (chc_line.Checked)
            {
                if (StaInspect.Instance.PrjID == 0)
                {
                    StaInspect.Instance.initSwitch(0, 3);//设置检测模式
             
                }
                if (StaInspect.Instance.PrjID == 1)
                {
                    StaInspect.Instance.initSwitch(1, 4);//设置检测模式
                }
            }
            else
            {
                if (StaInspect.Instance.PrjID == 0)
                {
                    StaInspect.Instance.initSwitch(0);//设置检测模式
        
                }
                else
                {
                    StaInspect.Instance.initSwitch(1);//设置检测模式
            
                }
            }
            txt_z.Text = StaInspect.Instance.Rbt.GetCurPos().z.ToString();
            StaInspect.Instance.Rbt.StopALL(true);
            StaInspect.Instance.ReadImageOnly();
        }


        private void MenuItemProjectOtherSave_Click(object sender, EventArgs e)
        {
            using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog())
            {
                folderBrowserDialog.Description = "选择保存路径";
                DialogResult dialogResult = folderBrowserDialog.ShowDialog();

                if (dialogResult == DialogResult.OK)
                {
                    StaInspect.Instance.loadPath = folderBrowserDialog.SelectedPath;
                    StaInspect.Instance.Save(folderBrowserDialog.SelectedPath);
                    StaConfig.Instance.Save(folderBrowserDialog.SelectedPath);
                    MessageBox.Show("保存成功！");
                }
            }
        }





        private void button3_Click(object sender, EventArgs e)
        {
            StaInspect.Instance.Rbt.SetDO(1, 0);
        }



        private void btnAddLight_Click(object sender, EventArgs e)
        {

            if (StaInspect.Instance.prjLight == 255)
            {
                MessageBox.Show("亮度值不能大于255");
                return;
            }
            StaInspect.Instance.prjLight++;
            StaInspect.Instance.lightProc(StaInspect.Instance.prjLight);
            textBoxLight.Text = StaInspect.Instance.prjLight.ToString();
            StaInspect.Instance.ReadImageOnly();

        }

        private void btnDecLight_Click(object sender, EventArgs e)
        {
            if (StaInspect.Instance.prjLight == 0)
            {
                MessageBox.Show("亮度值不能小于0");
                return;
            }

            StaInspect.Instance.prjLight--;
            StaInspect.Instance.lightProc(StaInspect.Instance.prjLight);
            textBoxLight.Text = StaInspect.Instance.prjLight.ToString();
            StaInspect.Instance.ReadImageOnly();
        }

        private void btnSetPos2_Click(object sender, EventArgs e)
        {
            try
            {
                StaInspect.Instance.Prj.g_dMaxVel = Convert.ToDouble(this.txt_sudu.Text.Trim());
            }
            catch (Exception)
            {


            }
        }

        private void btn_outList_Click(object sender, EventArgs e)
        {
            try
            {
                string str = "";
                for (int i = 0; i < errCells.Count; i++)
                {
                    var err = errCells[i];
                    TargetPos targetPos = StaInspect.Instance.Rbt.P2TPByOrig(err.Pos);
                    str += $"ID:{err.ID}  中心点 像素坐标:{err.Pos.X},{err.Pos.Y}  物理坐标:{targetPos.x},{targetPos.y}  状态:{err.Status}  角度:{err.Angle}\n";

                }
                long t = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
                string pathAName = StaInspect.Instance.loadPath + "\\" + t.ToString() + "导出.txt";
                FileStream fs;
                //判断是否已经有了这个文件
                if (!System.IO.File.Exists(pathAName))
                {
                    //没有则创建这个文件,创建写入文件，设置文件属性为隐藏
                    fs = new FileStream(pathAName, FileMode.Create, FileAccess.Write);
                }
                else
                {
                    //调用File类的Delete()方法删除C盘根目录下的Test.txt文本文件
                    System.IO.File.Delete(pathAName);
                    //fs = new FileStream(pathAName, FileMode.Open, FileAccess.Write);
                    fs = new FileStream(pathAName, FileMode.Create, FileAccess.Write);
                }
                File.SetAttributes(@pathAName, FileAttributes.Hidden);
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(str.Trim());//写入值
                sw.Flush();
                sw.Dispose();
                sw.Close();
                fs.Close();
                MessageBox.Show("列表数据导出成功!");
            }
            catch (Exception)
            {


            }
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("explorer.exe", StaInspect.Instance.loadPath);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            IEnumerable<int> FindDiscontinuousNumbers(IEnumerable<int> numbers)
            {
                int expectedNumber = 1;
                var discontinuousNumbers = new List<int>();

                foreach (var number in numbers.OrderBy(n => n))
                {
                    if (number != expectedNumber)
                    {
                        discontinuousNumbers.Add(expectedNumber);
                    }
                    expectedNumber++;
                }

                return discontinuousNumbers;
            }
            bool IsDataContiguous(IEnumerable<int> data)
            {
                if (data == null || !data.Any())
                    return false;

                var sortedData = data.OrderBy(x => x).ToList();
                return sortedData.Max() - sortedData.Min() == sortedData.Count() - 1;
            }

            if (errCells.Count < 0)
            {
                MessageBox.Show("请先检测，再更新列表！");
            }
            List<int> temp = new List<int>();
            for (int i = 0; i < errCells.Count; i++)
            {
                var err = errCells[i];
                TargetPos targetPos = StaInspect.Instance.Rbt.P2TPByOrig(err.Pos);
                temp.Add(err.ID);

            }
            var duplicates = temp.GroupBy(n => n)
                               .Where(g => g.Count() > 1)
                               .Select(g => g.Key);

            string str = "";
            foreach (var number in duplicates)
            {
                str += number + " ";
            }
            // bool hasDuplicates = temp.GroupBy(x => x).Any(g => g.Count() > 1);
            if (!string.IsNullOrEmpty(str))
            {
                MessageBox.Show("cell数据验证失败,有重复cellID！查询到重复ID:" + duplicates.ToString());
                return;
            }

            temp.Sort();

            var Numbers = FindDiscontinuousNumbers(temp);

            Console.WriteLine("不连续的数字有：");
            str = "";
            foreach (var number in Numbers)
            {
                str += number + " ";
            }




            if (!string.IsNullOrEmpty(str))
            {
                MessageBox.Show("cell数据验证失败,cellID不连续！ID：" + str);
                return;
            }
            MessageBox.Show("cell数据验证成功！！！");

        }
        Thread inspectThread;   //运动线程
        private void button5_Click(object sender, EventArgs e)
        {
            inspectThread = new Thread(new ThreadStart(Run_check));
            inspectThread.IsBackground = false;
            inspectThread.Start();
        }
        private void Run_check()
        {
            int i = 0;
            AddNUM(i.ToString());
            while (true)
            {
                if (!StaInspect.Instance.IsBusy())
                {
                    if (i == 20)
                    {
                        AddNUM(i.ToString());
                        break;
                    }
                    StaInspect.Instance.StartInspect();
                    i++;
                    AddNUM(i.ToString());
                }
                Thread.Sleep(1500);
            }
            inspectThread.Abort();
            AddNUM("检测完成");

        }

        private void AddNUM(string str)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new Action(() =>
                {
                    label9.Text = str;
                }));
            }
            else
            {
                label9.Text = str;
            }
        }

        //private void btn_LineA2_Click(object sender, EventArgs e)
        //{
        //    TargetPos tt = StaInspect.Instance.GetCurPos();
        //    txt_lineA2.Text = tt.ToString();
        //    StaInspect.Instance.PrjList[2].sketchOrig = tt;
        //}

        //private void btn_LineB2_Click(object sender, EventArgs e)
        //{
        //    TargetPos tt = StaInspect.Instance.GetCurPos();
        //    txt_lineB2.Text = tt.ToString();
        //    StaInspect.Instance.PrjList[3].sketchOrig = tt;
        //}

        //private void btn_LineA2_Z_Click(object sender, EventArgs e)
        //{
        //    StaInspect.Instance.PrjList[2].sketchOrig.z = StaInspect.Instance.Rbt.GetCurPos().z;
        //    txt_lineA2_Z.Text = StaInspect.Instance.Rbt.GetCurPos().z.ToString();
        //}

        //private void btn_LineB2_Z_Click(object sender, EventArgs e)
        //{
        //    StaInspect.Instance.PrjList[3].sketchOrig.z = StaInspect.Instance.Rbt.GetCurPos().z;
        //    txt_lineB2_Z.Text = StaInspect.Instance.Rbt.GetCurPos().z.ToString();
        //}
    }
}
